#ifndef ODBCSTATEMENTEXECUTOR_H_JM_20121205
#define ODBCSTATEMENTEXECUTOR_H_JM_20121205

// ##
#include "StatementExecutor.h"
// ## C++
#include <vector>
#include <string>
// ## windows
#include <Windows.h>
#include <sqltypes.h>

namespace jmlib {

	class  OdbcStatementExecutor : public StatementExecutor {
	public:
		static SQLTCHAR* CONNECTION_STRING;

		static const int STRING_DATA_SIZE = 64;
		static const int INTEGER_DATA_SIZE = 0;
		typedef char StringDataType[STRING_DATA_SIZE];
		typedef int IntegerDataType;

		/// Typ popisu typov v tabulke.
		typedef std::vector<int> ColumnSQLTypes;

		virtual void execute(const std::string& statement, 
			DataTarget* target) override;

	private:

		SQLHANDLE enviromentHandle_;    
		SQLHANDLE connectionHandle_;
		SQLHANDLE statementHandle_;

		/// Uvolnenie alokovanych SQL handlerov potrebnych pre komunikaciu s DB.
		void releaseSQLHandles();
		/// Inicializacia prostredia pre ODBC komunikaciu (krok 1).
		bool initEnviroment();
		/// Spojenie s ODBC (krok2).
		bool connect(); 
		/// Zaslanie statementu skrz ODBC do DB (krok 3).
		//bool sendStatement(LPCTSTR statement);
		bool sendStatement(const std::string& statement);
	};

} // namespace jmlib


#endif
